package userchannellogic

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/assets-rpc/internal/dao/model/user/channel"
	"gitee.com/liuxuezhan/ar-platform/assets-rpc/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/assets-rpc/rpc"
	"gitee.com/liuxuezhan/ar-platform/base-common/pkg/xcode"
	"github.com/zeromicro/go-zero/core/logx"
)

type UserBankCountLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserBankCountLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserBankCountLogic {
	return &UserBankCountLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserBankCountLogic) UserBankCount(in *rpc.UserBankCountRequest) (*rpc.UserBankCountResponse, error) {
	userId := in.UserId
	if userId == 0 {
		return nil, xcode.UserNotFound
	}

	count := channel.NewBankModel(l.ctx, l.svcCtx.Db).CountShowUser(userId)

	return &rpc.UserBankCountResponse{
		Count: count,
	}, nil
}
